Skip to content

feat: add Zig language support#70

Merged
Helweg merged 4 commits into
Helweg:mainfrom
emanspeaks:zig
May 8, 2026
Merged

feat: add Zig language support#70
Helweg merged 4 commits into
Helweg:mainfrom
emanspeaks:zig

Conversation

@emanspeaks
Copy link
Copy Markdown
Contributor

@emanspeaks emanspeaks commented May 3, 2026

Summary

Adds first-class Zig support to the indexer: tree-sitter semantic parsing, file-pattern discovery, and call-graph extraction for .zig files.

Changes

  • Adds tree-sitter-zig grammar dependency and wires it into the native parser registry.
  • Registers **/*.zig glob in DEFAULT_INCLUDE for file discovery.
  • Semantic node kinds: function_declaration, test_declaration, struct_declaration, enum_declaration, union_declaration, opaque_declaration, error_set_declaration.
  • Comment kinds: line_comment, doc_comment.
  • Call graph support via native/queries/zig-calls.scm — covers direct calls, method/field calls, and builtin calls (@import, @This, etc.).
  • Wires Zig into CALL_GRAPH_LANGUAGES and CALL_GRAPH_SYMBOL_CHUNK_TYPES in src/indexer/index.ts.
  • Updates README supported-language table and default file patterns.
  • tests/config.test.ts updated for the new DEFAULT_INCLUDE entry count.

Testing

  • Unit tests added/updated — parser test in tests/native.test.ts (function/struct declarations become chunks); call-graph tests in tests/call-graph.test.ts (direct calls and @import builtins).
  • Manual testing performed
  • Build passes (npm run build)
  • Typecheck passes (npm run typecheck)
  • Tests pass (npm run test:run)
  • Lint passes (npm run lint)

Release Labels

  • Added at least one release category label (feature)
  • Added at most one semver label when needed (semver:minor)

Related Issues

N/A.

Notes for reviewer

This PR and the Fortran PR both touch CALL_GRAPH_LANGUAGES and CALL_GRAPH_SYMBOL_CHUNK_TYPES in src/indexer/index.ts. Whichever merges second will need a trivial conflict resolution to keep both languages in the lists.

@github-actions github-actions Bot added dependencies Dependency updates documentation Documentation changes test Test changes labels May 3, 2026
@emanspeaks
Copy link
Copy Markdown
Contributor Author

resolved merge conflicts on this one, hopefully good to go with the current state of main

emanspeaks and others added 2 commits May 5, 2026 19:31
- Add tree-sitter-zig grammar for semantic parsing of .zig files
- Register .zig extension in DEFAULT_INCLUDE file discovery
- Add ZIG_SEMANTIC_NODES: function_declaration, test_declaration,
  struct/enum/union/opaque/error_set declarations
- Add line_comment and doc_comment support via is_comment_node
- Add native/queries/zig-calls.scm for call graph extraction
- Wire Zig into CALL_GRAPH_LANGUAGES and CALL_GRAPH_SYMBOL_CHUNK_TYPES
- Fix Windows path separator issue in src/native/index.ts isDevMode check
- Update config test length for new DEFAULT_INCLUDE entry
- Update README supported languages and default file patterns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@Helweg Helweg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posting the verified Zig follow-ups from review.

Comment thread native/src/parser.rs Outdated
Comment thread native/queries/zig-calls.scm Outdated
Comment thread native/queries/zig-calls.scm
Comment thread tests/native.test.ts
…upport

- Switch Zig comment detection from `line_comment | doc_comment` to
  `comment` (tree-sitter-zig emits all comments under a single node type,
  so doc comments were never attaching to semantic chunks)
- Tag field-expression call pattern with `@method.call` so that
  std.debug.print-style calls are classified as MethodCall
- Add dedicated `@import.name` / `@import` capture for builtin_function
  nodes with a string argument, promoting @import("std") from a generic
  builtin call to a proper import edge
- Strengthen Zig tests: assert function_declaration / test_declaration
  chunk types, verify doc-comment attachment, and assert MethodCall and
  Import call types rather than no-crash checks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@emanspeaks
Copy link
Copy Markdown
Contributor Author

Claude took a shot at trying to address your comments since I am far from a tree-sitter expert, but let me know if that is insufficient still.

@Helweg Helweg merged commit 53c2d06 into Helweg:main May 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependency updates documentation Documentation changes test Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants